/* Gauge - Performance Measurement Framework for Mobile Platforms
 * Copyright (C) 2013, Juha Hytonen <juha.a.hytonen@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.gauge.ExampleBenchmarks;

import org.gauge.Benchmark;
import org.gauge.Probes.*;

import org.gauge.ExampleBenchmarks.Workloads.*;

/**
 * Example contextual benchmark for Gauge performance measurement framework.
 * 
 * This example demonstrates how to create contextual benchmarks with Gauge.
 */
public class ExampleContextualBenchmark extends Benchmark {

	@Override
	public String GetName() {
		// Name will be used in resulting file names etc.
		return "Example Contextual Benchmark";
	}
	
	@Override
	public void Setup() {
		// A good practice is to read static probes once first.
		readProbe(TotalMainMemory.class);
		
		// Dynamic probes should be initialized then.
		readProbeEvery(MainMemoryUsage.class, 1000);
		readProbeEvery(ProcessorLoad.class, 1000);
	}

	@Override
	public void Run() {
		// First gather idle stats for 10 seconds.
		beforeNextActionWaitFor(10000);
		
		// This is where your custom workloads should be run.
		runWorkload(MusicPlayback.class);
		
		// We can wait for our workload to run for a while and then perform
		// some more actions...
		beforeNextActionWaitFor(10000);
		
		runWorkload(WebBrowsing.class);
		
		beforeNextActionWaitFor(20000);
		
		// If we don't know how long the workload runs, we can simply wait
		// for it to stop. Make sure that it eventually does!
		waitForWorkloadToStop(WebBrowsing.class);
		
		// Again gather idle stats.
		beforeNextActionWaitFor(10000);
	}

}
